﻿<div class="container">
    <div ng-controller="DanTocCtrl">
        <span ng-click="Add()" data-toggle="modal" data-target="#myModal" class="btn btn-success">
            Thêm mới
        </span>
        <div class="divList">
            <table class="table table-hover">
                <tr>
                    <td width="150"><b>Chức năng</b></td>
                    <td></td>
                    <td><b>STT</b></td>
                    <td><b>Mã</b></td>
                    <td><b>Tên</b></td>
                    <td><b>Diễn giải</b></td>
                    <td><b>Ghi chú</b></td>
                </tr>
                <tr ng-repeat="obj in objects">
                    <td>
                        <span ng-click="ViewUpdate(obj)" data-toggle="modal" data-target="#myModal" class="btn btn-primary">Sửa</span>
                        <span ng-click="Delete(obj)" class="btn btn-danger">Xóa</span>
                    </td>
                    <td>
                        <input type="hidden" name="someData" ng-value="obj.Id" />
                    </td>
                    <td>
                        {{obj.STT}}
                    </td>
                    <td>
                        {{obj.Ma}}
                    </td>
                    <td>
                        {{obj.Ten}}
                    </td>
                    <td>
                        {{obj.DienGiai}}
                    </td>
                    <td>
                        {{obj.GhiChu}}
                    </td>
                </tr>
            </table>
        </div>

        <!--Modal-->
        <div class="modal fade" tabindex="-1" id="myModal" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">Dân tộc</h4>
                    </div>

                    <div class="modal-body">
                        <form class="form-horizontal" name="DMForm">
                            <div class="form-group">
                                <label for="STT" class="col-sm-2 control-label">STT</label>
                                <div class="col-sm-10">
                                    <input id="STT" type="number" class="form-control" ng-model="obj.STT">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="Ma" class="col-sm-2 control-label">Mã</label>
                                <div class="col-sm-10">
                                    <input id="Ma" name="Ma" type="text" class="form-control" required ng-model="obj.Ma">
                                    <div class="error">
                                        <span ng-show="DMForm.Ma.$error.required && DMForm.Ma.$dirty">
                                            Chưa nhập mã.
                                        </span>
                                    </div>
                                    <!--<div class="error">
                                        <span ng-show="DMForm.Ma.$valid">
                                            Mã đã tồn tại, nhập mã khác.
                                        </span>
                                    </div>-->
                                </div>

                            </div>
                            <div class="form-group">
                                <label for="Ten" class="col-sm-2 control-label">Tên</label>
                                <div class="col-sm-10">
                                    <input id="Ten" name="Ten" type="text" class="form-control" required ng-model="obj.Ten">
                                    <div class="error">
                                        <span ng-show="DMForm.Ten.$error.required && DMForm.Ten.$dirty">
                                            Chưa nhập tên.
                                        </span>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="DienGiai" class="col-sm-2 control-label">Diễn giải</label>
                                <div class="col-sm-10">
                                    <textarea id="DienGiai" class="form-control" rows="2" style="min-width: 100%" ng-model="obj.DienGiai"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="GhiChu" class="col-sm-2 control-label">Ghi chú</label>
                                <div class="col-sm-10">
                                    <textarea id="GhiChu" class="form-control" rows="2" style="min-width: 100%" ng-model="obj.GhiChu"></textarea>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" ng-click="Save(obj,false,true)" ng-disabled="DMForm.$invalid">Lưu và Thêm mới</button>
                        <button type="button" class="btn btn-success" ng-click="Save(obj,true)" ng-disabled="DMForm.$invalid" saveandclosemodal="#myModal">Lưu và Đóng</button>
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Đóng</button>
                    </div>

                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
    </div>
</div>






